package com.archway.nearshop.zdemo.ademo.mvc;

import java.util.HashMap;
import java.util.Map;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.archway.appframe.web.auth.session.SessionBean;
import com.archway.appframe.web.servlet.bind.OutputObject;

@Controller
@RequestMapping("/login")
public class TestLoginController {
	
    @Autowired
    private SessionBean sessionBean;

	@RequestMapping(value="/login" ,method=RequestMethod.POST) 
	public @ResponseBody OutputObject doLogin(@RequestBody String requestInfo) {//,Map<String, Object> model
		//UserInfoSession.LoginUser  user = new UserInfoSession().new LoginUser();
		//sessionBean.setAlive(true);
		//sessionBean.setLoginUser(user);
		System.out.println(sessionBean.isAlive());
		sessionBean.setAlive(true);
		System.out.println("hello===");
		OutputObject output = new OutputObject(); 
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("login", "session setted now ");
		output.setBean(map);
		return output;
	}
	
	@RequestMapping(value="/logout" ,method=RequestMethod.POST) 
	public @ResponseBody OutputObject doLogout(@RequestBody String requestInfo) {//,Map<String, Object> model
		//System.out.println(sessionBean.getLoginUser().getUserId());
		
		
		OutputObject output = new OutputObject(); 
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("login", "session setted now ");
		output.setBean(map);
		return output;
	}
	
}
